" vim: ft=vim
" Subclassing dict class
Before;
let dict = object#dict_()
let MyDict = object#class('MyDict', dict)

function! MyDict.__init__(...)
  call call(object#super(g:MyDict, self).__init__, a:000)
endfunction


Execute(__missing__ returns);
function! MyDict.__missing__(Key)
  return a:Key
endfunction

let x = object#new(MyDict)
AssertEqual object#getitem(x, 'foo'), 'foo'
Assert !x.has_key('foo')


Execute(__missing__ throws);
function! MyDict.__missing__(Key)
  throw object#Exception('')
endfunction

let x = object#new(MyDict)
AssertThrows call object#getitem(g:x, 'foo')
Assert g:vader_exception =~# 'Exception'

Execute(No __missing__);
let x = object#new(MyDict)
AssertThrows call object#getitem(g:x, 'foo')
Assert g:vader_exception =~# 'KeyError'
